package week_10;

public class ReverseBits_190 {
    public int reverseBits(int n) {
        int ans=0;
        for(int i=0;i<32;i++)
            ans =(ans<<1)|(n>>i&1);
        return ans;
    }

    public int reverseBits2(int n) {
        int n1=n;
        for(int i=0;i<16;i++){
            int l=(n>>i)&1;
            int r =(n>>(31-i))&1;
            if(l!=r){
                n= n^(1<<i);
                n=n^(1<<(31-i));
            }
        }
        return n;
    }
}
